home *** CD-ROM | disk | FTP | other *** search
- #!/sprite/cmds/csh -f
- #
- # A script to generate (or regenerate) the Makefile for a directory
- # consisting solely of header files.
- #
- # We assume we were invoked from mkmf. Parameters passed in from mkmf
- # through environment variables:
- #
- # MKMFDIR directory containing prototype makefiles
- # MAKEFILE name of makefile to create
- # SUBTYPE additional information, telling whether this
- # is an X directory, Sprite directory, etc.
- #
-
- #
- # Argument processing. (Generalized form, even though just one flag so far.)
- #
- while ($#argv >= 1)
- if ("$1" == '-x') then
- set echo
- endif
- shift
- end
-
- set name=`expr $cwd : '.*/man/\(.*\)$'`
- set subtype=$SUBTYPE
- set makefile=$MAKEFILE
- set distdir=($DISTDIR)
-
- if (-e $makefile.proto) then
- set proto=$makefile.proto
- else
- set proto="${MKMFDIR}/Makefile.man"
- endif
-
- echo "Generating a Makefile for $name manual entries using $proto"
-
- set nonomatch
- set manPages =( *.man )
- #
- # Check to see if there were any man pages. The first check (size == 1)
- # is only necessary because the second check will cause an error if
- # hdrs contains more than 1024 bytes.
- #
- if ($#manPages == 1) then
- if ("$manPages" == "*.man") set manPages=()
- endif
- unset nonomatch
-
- #
- # Use sed to substitute various interesting things into the prototype
- # makefile. The code below is a bit tricky because some of the variables
- # being substituted in can be very long: if the substitution is passed
- # to sed with "-e", the entire variable must fit in a single shell argument,
- # with a limit of 1024 characters. By generating a separate script file
- # for the very long variables, the variables get passed through (to the
- # script file) as many arguments, which gets around the length problem.
- #
-
- rm -f mkmf.tmp.sed
- echo s,"@(MANPAGES)",$manPages,g > mkmf.tmp.sed
- cat $proto | sed -f mkmf.tmp.sed \
- -e "s,@(DATE),`date`,g" \
- -e "s,@(MAKEFILE),$makefile,g" \
- -e "s,@(NAME),$name,g" \
- -e "s,@(TEMPLATE),$proto,g" \
- -e "s,@(TYPE),$subtype,g" \
- -e "s,@(DISTDIR),$distdir,g" \
- > $makefile
- rm -f mkmf.tmp.sed
-